/*
 * LotQtyPullTag.java
 *
 * Created on June 18, 2003, 8:30 PM
 */

package com.scalar.chiptrack.operations.packingslip.tags;

/**
 *
 * @author  Balaram Putta
 * @version
 */

import java.util.ArrayList;

import javax.servlet.jsp.tagext.TagSupport;

import com.scalar.ScalarException;
import com.scalar.chiptrack.operations.packingslip.dao.FinalInventoryDAO;


public class LotQtyPullTag extends TagSupport
{

    private String m_partNumber = null;
    private int m_lineItemId = -1;
    private int m_csLineItemId = -1;
    private boolean m_inverseFunctionality = false;

    public String getPartNumber()
    {
        return m_partNumber;
    }
    public void setPartNumber( String partNumber )
    {
        m_partNumber = partNumber;
    }

    public int getLineItemId()
    {
        return m_lineItemId;
    }
    public void setLineItemId( int lineItemId )
    {
        m_lineItemId = lineItemId;
    }

    public int getCsLineItemId()
    {
        return m_csLineItemId;
    }
    public void setCsLineItemId( int csLineItemId )
    {
        m_csLineItemId = csLineItemId;
    }

    public boolean getInverseFunctionality()
    {
        return m_inverseFunctionality;
    }
    public void setInverseFunctionality( boolean inverseFunctionality )
    {
        m_inverseFunctionality = inverseFunctionality;
    }

    public int doStartTag()
    {
        int lineItemCount = -1;
        try
        {

			ArrayList lineItemList ;


				lineItemList = FinalInventoryDAO.loadFinalInventoryDataByPartNumberAndLineItem( m_partNumber, m_lineItemId+"", m_csLineItemId+"");


            if( lineItemList != null )
            {
                lineItemCount = lineItemList.size();
            }
        }
        catch( ScalarException se )
        {
            se.getRootCause().printStackTrace();
        }

        if( lineItemCount > 0 )
        {
            if( m_inverseFunctionality )
            {
                return SKIP_BODY;
            }

            return EVAL_BODY_INCLUDE;
        }

        if( m_inverseFunctionality )
        {
            return EVAL_BODY_INCLUDE;
        }

        return SKIP_BODY;
    }

}